#include<iostream>
#include<vector>
#include<algorithm>	
#include <climits>
using namespace std;
struct shu{
	int value;
	int a;//绝对值
	bool operator<(shu&other){
		if(other.a ==a)
		return value<other.value ;
		return a<other.a;
	}
};



int main(){
	int n;
	cin>>n;
	vector<shu>s;
	int t;

    int max = INT_MIN;
    int min = INT_MAX;
	while(n--){
		cin>>t;
		shu v1={t,0};
		s.push_back(v1) ;
		if(t>max)max=t;
		if(t<min)min=t;
	}
	
	for(auto&c:s){
		c.a=abs(abs(c.value-max)-(c.value-min));
	}
	sort(s.begin(),s.end());
	cout<<s[0].value <<endl;
	return 0;
}